//
//  Contact.m
//  OC6_作业练习
//
//  Created by dllo on 15/11/1.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "Contact.h"

@implementation Contact

- (id)initWithName:(NSString *)name sex:(NSString *)sex phone:(NSString *)phone address:(NSString *)address group:(NSString *)group age:(NSInteger)age
{
    self = [super init];
    if (self) {
        [self setName:name];
        [self setSex:sex];
        [self setPhone:phone];
        [self setAddress:address];
        [self setGroup:group];
        [self setAge:age];
    }
    return self;
}

- (NSComparisonResult)compareByName:(Contact *)contact
{
    return [[self name] compare:[contact name]];
    }


- (NSComparisonResult)compareByAge:(Contact *)contact
{
    if ([self age] > [contact age]) {
        return NSOrderedAscending;
    }else if ([self age] < [contact age]){
        return NSOrderedDescending;
    }else{
        return NSOrderedSame;
    }
}







@end
